<template>
	<view class="aboutus">
		<!-- 顶部导航 -->
		<diyNavBar value='关于我们'></diyNavBar>
		<!-- 二维码 -->
			<view class="code">
				<image :src="$util.img(image)" mode="widthFix" @click="saveImage"></image>
				<text class="tips">点击保存图片</text>
				<text>小黄人官方群</text>
			</view>
	</view>
</template>

<script>
	import diyNavBar from '../../component/diy-nav/diy-navbar.vue'
	export default{
		components:{diyNavBar},
		data(){
			return {
				getData:{},
				image:''
			}
		},
		onShow() {
			this.$http.sendrequest('/index/gymy',{},{
				tokenJudge:true
			}).then(res=>{
				if(res.code == 1) this.getData = res.data;
				this.image = res.data.value
				console.log("this.image",this.image)
			})
		},
		methods: {
			saveImage() {
				// #ifdef H5
				this.$util.getImglocal(this.$util.img(this.image))
				// #endif
				// #ifdef APP
				let that = this;
				uni.showModal({
					content: '是否保存图片到相册',
					success: (res) => {
						uni.hideLoading();
						if (res.confirm) {
							// 向用户发起授权请求
							that.downLoadImg();
						}
					}
				});
				// #endif
			},
			/**
			 * 下载资源，保存图片到系统相册
			 */
			downLoadImg() {
				uni.showLoading({
					title: '加载中'
				});
				uni.downloadFile({
					url: this.$util.img(this.image),
					success: (res) => {
						uni.hideLoading();
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.showToast({
										title: "保存成功",
										icon: "none"
									});
								},
								fail: function() {
									uni.showToast({
										title: "保存失败，请稍后重试",
										icon: "none"
									});
								}
							});
						}
					},
					fail: (err) => {
						uni.showToast({
							title: "失败啦",
							icon: "none"
						});
					}
				})
			},
			/*
			 * 引导用户开启权限
			 */
			isAuth() {
				uni.showModal({
					content: '由于您还没有允许保存图片到您相册里,无法进行保存,请点击确定允许授权',
					success: (res) => {
						if (res.confirm) {
							uni.openSetting({
								success: (result) => {
									console.log(result.authSetting);
								}
							});
						}
					}
				});
			},
			/**
			 * 跳转qq
			 */
			tzqq(){
				// #ifdef H5
				window.location.href = this.getdata[2].value;
				// #endif
				// #ifdef APP
				plus.runtime.openURL(this.getdata[2].value);
				// #endif
			}
		}
	}
</script>

<style lang="scss" scoped>
	.aboutus{
		min-height: 100vh;
		background: $uni-content-background-color;
		.code{
			padding: 60rpx 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			
			image{
				width: 304rpx;
				height: 304rpx;
			}
			text{
				font-size: 32rpx;
			}
			.title {
				font-size: 32rpx;
				font-weight: bold;
				margin: 20rpx 0 72rpx;
			}
			.tips{
				font-size: 24rpx;
				color: rgba(0,0,0,.2);
				margin-top: 20rpx;
			}
			
		}
		.introduce{
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 90rpx;
			background: #FFFFFF;
			padding: 0 30rpx;
			border-bottom: 2rpx solid rgba(0,0,0,.02);
			.text{
				font-size: 26rpx;
				color: #515151;
			}
			
			
		}
	}
</style>
